/*
 * pattern.h
 *
 *  Created on: 19-05-2013
 *      Author: Artur Góralewski
 */

#ifndef PATTERN_H_
#define PATTERN_H_

#define READ_PATTERN 0
#define INPUT_PATTERN 1

#include "tuple.h"

//maximum number of elements in a tuple
#define MAX_SIZE_OF_PATTERN 50

//comparison_operator {==, < , <=, >, >=}
typedef enum {EQUAL, SMALLER, NOT_LARGER, LARGER, NOT_SMALLER} comparison_operator;

//element in tuple
typedef struct element_p
{
	struct element_p *next;
	type_of_data type;
	comparison_operator comp_oper;
	data data;
	_Bool valid_data; // when 0 data contains *

} element_of_pattern;

//tuple
typedef struct
{
	element_of_pattern* first;
	int pattern_type;  //READ_PATTERN or INPUT_PATTERN

}pattern;

//function that creates the pattern
//its args are first - is number of elements in the pattern
//the rest of args are elements_of_pattern
pattern* create_pattern(const int amount_args, ...);

//additional function that adds a element to the tuple
void add_elem_to_pattern (pattern *pat, const element_of_pattern elem);

//function that prints the tuple
void print_pattern(const pattern *pat);

//function that deletes the tuple
void delete_pattern(pattern *pat);

//function that compare pattern with tuple
_Bool comparison(const pattern *pat, const tuple *tup);

#endif /* PATTERN_H_ */
